import os
import random
import json

"""
免费代理获取：需要去批量获取后保存到ip_pool中
https://www.kuaidaili.com/
https://www.zdaye.com/
http://http.py.cn/api/
"""

def get_bili_cfg():
    json_file = "cfg.json"
    with open(json_file) as f:
        cfg = json.load(f)
    return cfg

exec_script = "popular_science.py"

cfg = get_bili_cfg()
blocks = cfg["blocks"]
if blocks <= 0:
    print("[ERR ] blocks must >= 1")

force_noproxy = True

for block_id in range(0, blocks):
    print("[INFO] 启动调度块：", block_id)
    
    cmd_str = "start python " + exec_script + " block" + str(block_id)
    os.system(cmd_str)

print("[INFO] 启动所有调度块完成！")
